
import redis, os, sys, time, random

sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

from exchange.utils.uuid import uuid
from exchange.conf.conf import conf

# redis
rdb = redis.Redis(host=conf.redis.host, port=conf.redis.port, db=conf.redis.db, decode_responses=True)

count = 10000

while count > 0:

    count -= 1

    # print(count)

    account = uuid.get_tick()
    symbol  = "swtc/cnyt"
    action  = "sell"
    if random.randint(0,100) > 50:
        action = "buy"
    price   = round(random.random(), 6)
    amount  = round(random.random()* 100.00, 6)

    data = "order,%s,%s,%s,%.6f,%.6f" % (account, symbol, action, price, amount)

    print(data)

    rdb.lpush("queue", data)

    time.sleep(0.001)
